﻿using Newtonsoft.Json;
using Superstore.Vender.App_Code;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Superstore.Vender.Controllers
{
    public class LocationController : Controller
    {
        // GET: Location
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 获取用户缓存的地理信息
        /// </summary>
        /// <param name="openId"></param>
        /// <returns></returns>
        [HttpPost]
        public string GetLocationFromCatch(string openId)
        {
            if (openId != null && openId.ToString() != "")
            {
                var locationInfo = new KeyValuePair<double, double>(WXInfoCacheMgr.GetLatitude(openId), WXInfoCacheMgr.GetLongitude(openId));
                return JsonConvert.SerializeObject(locationInfo);
            }
            else
            {
                return "";
            }           
        }
    }
}